<!-- 
  @description 所属商家
  @author cjs
  @date 2021-07-17 10:20:13
-->
<template>
	<el-cascader v-model="val"
	  :options="options"
    :props="props"
	  @change="handleChange"></el-cascader>
</template>
<script>

export default {
  props: {
    value: {
      type: [ String, Number ],
      default: ""
    }
  },
  data() {
    return {
      val: "",
      options: [],
      props: {
        expandTrigger: "click",
        checkStrictly: true,
        emitPath: false,
        value: "id",
        label: "zzjg_name",
        children: "children"
      },
    };
  },
  watch: {
    value() {
      this.val = this.value;
    }
  },
  mounted() {
    this.val = this.value;
    this.getDepartmentList();
  },
  methods: {
    /**
     * @name handleChange
     * @description 切换方法
     * @param {}
     * @author cjs
     * @date 2021-07-17 10:23:00
     */
    handleChange(val) {
      this.$emit("input", val);
    },
    /**
     * @name getDepartmentList
     * @description 获取用户组织机构
     * @param {}
     * @author cjs
     * @date 2021-07-17 10:21:53
     */
    async getDepartmentList() {
      let data = {
        searchName: ""
      };
      const res = await this.$store.dispatch(
        "qxgl-yhzzgl/getDepartmentList",
        data
      );
      this.options = res.data || [];
      this.$emit("getDeptList", res.data);
    }
  }
}
</script>
<style lang="scss" scoped>
</style>